# encoding    : utf-8 -*-                            
# @author     :
# @file       :   优化.py
# @Time       :   2024/12/5 19:04
import pytest
from pom_appium_class_object.Excel_Data.ExcelData import ExcelData
from appium import webdriver
from pom_appium_class_object.Sina_Page.SinaPage import AppPage



# 固定的用户名和密码
USERNAME = "your_username"
PASSWORD = "your_password"


@pytest.fixture()
def setup():
	caps = {
		"appActivity": ".SplashActivity",
		"platformName": "Android",
		"platformVersion": "12",
		"deviceName": "127.0.0.1:7555",
		"appPackage": "com.sina.weibo",
		"automationName": "UiAutomator2"
	}
	url = "http://127.0.0.1:4723/wd/hub"
	driver = webdriver.Remote(url, caps)

	# 创建AppPage实例并调用登录方法
	app_page = AppPage(driver)
	app_page.login(USERNAME, PASSWORD)  # 在这里进行登录

	yield app_page  # 返回AppPage实例给测试用例
	driver.quit()


@pytest.mark.parametrize("keyword", ExcelData.read_test_data_from_excel())
def test_search_keyword(setup, keyword):
	setup.click_agreement()
	setup.click_discover()
	setup.click_known()
	setup.click_search_box()
	setup.enter_search_box_send(keyword)
	setup.perform_search()
	setup.swipe_page()
